<template>
  <div>
    <a-card :bordered="false">
      <f-search-form @searchHandler="searchHandler">
        <f-search-form-item label="商品名称" name="productName"/>
      </f-search-form>
      <f-table ref="table" size="default" rowKey="orderEvaluateId" :scroll="scroll" :columns="columns" handler="shopEvaluateListHandler" :operator="operator" :params="queryParam" :api="api.evaluate">
        <span slot="avatar" slot-scope="text, record, index">
          <img v-lazy="record.avatar" v-viewer class="radius-img">
        </span>
        <span slot="productTitle" slot-scope="text, record, index">
          <ellipsis :length="40" tooltip lines="4">
          {{record.productTitle}}
          </ellipsis>
        </span>
        <span slot="evaluateImages" slot-scope="text, record, index">
            <f-images :value="text"></f-images>
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a href="javascript:;" @click="$refs.table.remove(record.orderEvaluateId)">删除</a>
            <a-divider type="vertical"/>
          </template>
        </span>
      </f-table>

    </a-card>
  </div>
</template>

<script>
  import Ellipsis from '../../../../components/Ellipsis/Ellipsis'

  export default {
    name: 'TableList',
    components: { Ellipsis },
    data() {
      return {
        //列表初始化查询参数
        queryParam: {},
        scroll: { x: 1350 },
        // 表头
        columns: [{
          title: '#',
          align: 'center',
          customRender: (text, record, index) => index + 1
        },
          {
            title: '单号',
            align: 'center',
            dataIndex: 'orderNo'
          },
          {
            title: '商品名称',
            align: 'center',
            width: '150px',
            scopedSlots: { customRender: 'productTitle' }
          },
          {
            title: '评论人',
            align: 'center',
            dataIndex: 'avatar',
            scopedSlots: { customRender: 'avatar' }
          },
          {
            title: '买家',
            align: 'center',
            dataIndex: 'nickName'
          },
          {
            title: '描述评分',
            align: 'center',
            align: 'center',
            dataIndex: 'describeScore'
          },
          {
            title: '服务评分',
            align: 'center',
            dataIndex: 'evaluateScore'
          },
          {
            title: '评论内容',
            align: 'center',
            dataIndex: 'evaluateContent'
          },
          {
            title: '评论图',
            dataIndex: 'evaluateImages',
            sorter: true,
            width: '150px',
            align: 'center',
            scopedSlots: { customRender: 'evaluateImages' }
          },
          {
            title: '评论日期',
            dataIndex: 'createTime',
            sorter: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            scopedSlots: { customRender: 'action' }
          }
        ],
        //操作按钮
        operator: [
          {
            name: '删除',
            icon: 'delete',
            batch: true,
            handler: function(table) {
              table.remove()
            }
          }
        ]
      }
    },
    computed: {},
    methods: {
      getText: function(value) {
        if (value == 1) {
          return '已上架'
        }
        if (value == 2) {
          return '已下架'
        }
        if (value == 3) {
          return '违规下架'
        }
      },
      getImages(sku) {
        let images = sku.images
        if (images != '' && images.indexOf('[{') > -1) {
          let obj = JSON.parse(images)
          if (obj && obj.length > 0) {
            return obj[0].url
          }
        }
        return images
      }
    },
    created() {

    }
  }
</script>
<style scoped lang="less" rel="stylesheet/less">


</style>
